package models

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

type JsonResult struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type BaseQueryParam struct {
	Page int64 `json:"page"`
	Size int64 `json:"size"`
}

type LoginData struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type ResultList struct {
	List  interface{} `json:"list"`
	Count int64       `json:"count"`
}

func init() {
	//orm.RegisterModel(new(Admin))
	user := beego.AppConfig.String("mysqluser")
	pass := beego.AppConfig.String("mysqlpass")
	host := beego.AppConfig.String("mysqlurls")
	dbname := beego.AppConfig.String("mysqldb")
	conn := user + ":" + pass + "@tcp(" + host + ":3306)/" + dbname + "?charset=utf8"
	_ = orm.RegisterDriver("mysql", orm.DRMySQL)
	_ = orm.RegisterDataBase("default", "mysql", conn)
	orm.RegisterModelWithPrefix("tp_",
		new(Admin),
		new(Menu),
		new(AuthRule),
		new(AuthGroup),
		new(AuthGroupAccess),
		new(System),
		new(Attach),
		new(AttachType),
	)
}
